//
//  WSBaseHttp.h
//  WSBaseKit
//
//  Created by zhangcong on 2020/8/12.
//  Copyright © 2020 zhangcong. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "WSConst.h"


@interface WSBaseHttp : NSObject

/// 请求成功的状态码 项目子类重写 默认1000
@property (assign,nonatomic) NSInteger success_code;

/// 请求头 子类重写
@property (copy,nonatomic) NSDictionary<NSString *,NSString *> *headerDict;


/// 请求是否必须要token 具体项目里 子类重写
/// @param parameter <#parameter description#>
/// @param isMustToken <#isMustToken description#>
/// @param error <#error description#>
- (BOOL)addCurrentUserToken:(NSDictionary *)parameter isMustToken:(BOOL)isMustToken error:(ErrorBlock)error;

/**
 POST 请求
 
 @param url 请求路径
 @param params 请求参数
 @param needToken 该请求是否需要token
 */
- (void)POST:(NSString *)url params:(NSDictionary *)params needToken:(BOOL)needToken success:(SuccessBlock)success error:(ErrorBlock)errorBlock;

/**    需要token的POST请求     */
- (void)POST:(NSString *)url params:(NSDictionary *)params success:(SuccessBlock)success error:(ErrorBlock)errorBlock;

/**    POST请求     */
- (void)postRequest:(NSString *)path parameters:(NSDictionary *)parameters complete:(CompleteBlock)complete error:(ErrorBlock)errorBlock;

/**    GET请求     */
- (void)getRequest:(NSString *)path parameters:(NSDictionary *)parameters complete:(CompleteBlock)complete error:(ErrorBlock)errorBlock;

/**    PUT请求     */
- (void)putRequest:(NSString *)path parameters:(NSDictionary *)parameters complete:(CompleteBlock)complete error:(ErrorBlock)errorBlock;

/**    DELETE请求     */
- (void)deleteRequest:(NSString *)path parameters:(NSDictionary *)parameters complete:(CompleteBlock)complete error:(ErrorBlock)errorBlock;

/**
 *  解析单个model
 *
 *  @param data       数据
 *  @param modelClass model class
 *  @param complete   成功block
 *  @param errorBlock 失败block
 */
- (void)parseModel:(id)data modelClass:(Class)modelClass complete:(CompleteBlock)complete error:(ErrorBlock)errorBlock;

/**
 *  解析多个model
 *
 *  @param data       数据
 *  @param modelClass model class
 *  @param complete   成功block
 *  @param errorBlock 失败block
 */
- (void)parseModelArray:(id)data modelClass:(Class)modelClass complete:(CompleteBlock)complete error:(ErrorBlock)errorBlock;

/**
 *  单个Model HTTP 请求
 *
 *  @param path       请求路径
 *  @param parameters  请求参数
 *  @param modelClass model class 为nil时返回字典
 *  @param complete    成功block
 *  @param error      失败block
 */
- (void)postModelRequest:(NSString *)path parameters:(NSDictionary *)parameters modelClass:(Class)modelClass complete:(CompleteBlock)complete error:(ErrorBlock)error;

/**
 *  数组Model HTTP 请求
 *
 *  @param path       请求路径
 *  @param parameters  请求参数
 *  @param modelClass model class
 *  @param complete    成功block
 *  @param error      失败block
 */
- (void)postModelArrayRequest:(NSString *)path parameters:(NSDictionary *)parameters modelClass:(Class)modelClass complete:(CompleteBlock)complete error:(ErrorBlock)error;

- (BOOL)addCurrentUserToken:(NSDictionary *)parameter isMustToken:(BOOL)isMustToken error:(ErrorBlock)error;

/**    打印成json     */
+ (void)logResponseObject:(id)responseObject;
@end


